using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UFrame.Audio;
using System;

public class AudioAgent : AgentContext<AudioAgent, TableSoundCtrl>
{
    protected override void OnDestroy()
    {
        base.OnDestroy();
        AgentSelf.ClearCache();
    }

    public static void StartWithUserData(float musicVolume,float sfxVolume)
    {
        Instance.Initialize(1, 1, 1, new ResourceClipLoader());
        Instance.MusicVolume = musicVolume;
        Instance.SFXVolume = sfxVolume;
    }

    public static void SetBgmVolume(float volume)
    {
        Instance.MusicVolume = volume;
    }

    public static AudioContext PlayBgm1(int audioId, float volume, float patch)
    {
        return Instance.PlayAudioById(audioId, 1, volume, patch);
    }
    public static AudioContext PlayBgm2(int audioId, float volume, float patch)
    {
        return Instance.PlayAudioById(audioId, 2, volume, patch);
    }
    public static AudioContext PlayBgm3(int audioId, float volume, float patch)
    {
        return Instance.PlayAudioById(audioId, 3, volume, patch);
    }
    public static AudioContext PlayBgm4(int audioId, float volume, float patch)
    {
        return Instance.PlayAudioById(audioId, 4, volume, patch);
    }

    public static AudioContext PlayMusicChannel2(int audioId)
    {
        return Instance.PlayAudioById(audioId, 2, 1, 1);
    }

    public static AudioContext PlayAudioById(int audioId)
    {
        return Instance.PlayAudioById(audioId);
    }

    internal static void SetSfxVolume(float value)
    {
        Instance.SFXVolume = value;
    }

    public static AudioContext PlayAudioById(int audioId, Vector3 pos)
    {
        return Instance.PlayAudioById(audioId, pos);
    }

    internal static void SetMusicVolume(float value)
    {
        Instance.MusicVolume = value;
    }

    public static AudioContext PlayAudioById(int audioId, Vector3 pos, float pitch)
    {
        return Instance.PlayAudioById(audioId, pos, pitch: pitch);
    }


    public static void ClearCache()
    {
        Instance.ClearCache();
    }

}